package proxy.main.proxy;

import proxy.main.real.IRedWine;

/**
 * 红酒代理商
 */
public class RedWineProxy implements IRedWine {
    //真正的红酒生产厂商
    private final IRedWine redWine;

    //代理商出售红酒的权限
    private final boolean permission = true;

    public RedWineProxy(IRedWine redWine) {
        this.redWine = redWine;
    }


    /**
     * 代理商生产红酒方法（代理商不生产红酒，从真正的红酒工厂获取红酒）
     */
    @Override
    public void product() {
        if (this.permission) {
            //代理商有权限销售红酒，合法获取
            System.out.println("[合法的获取红酒工厂的正品红酒]");
            System.out.println("代理商接到订单，通知工厂送红酒...");
        } else {
            System.out.println("[非法红酒代理商]");
        }
    }

    @Override
    public void sell() {
        if (this.permission) {
            this.redWine.sell();
            System.out.println("代理商从工厂拿到批发价红酒，赚取差价出售...");
        } else {
            System.out.println("[非法红酒代理商]");
        }
    }
}
